package javacafe.action.freeboard;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javacafe.action.Action;
import javacafe.action.ActionForward;
import javacafe.dto.bbspost.BbsPostDTO;
import javacafe.dto.bbspost.BbsPostReplyDTO;
import javacafe.dto.member.LoginInfoDTO;
import javacafe.dto.study.StudyDTO;
import javacafe.dto.study.StudyMemberDTO;
import javacafe.dto.studybbs.StudyBBSDTO;
import javacafe.dto.studybbs.StudyBBSReplyDTO;
import javacafe.dto.studybbs.StudyPostDTO;
import javacafe.service.BbsPostService;
import javacafe.service.StudyBBSService;
import javacafe.service.StudyMemberService;
import javacafe.service.StudyService;
import javacafe.serviceimple.BbsPostServiceImple;
import javacafe.serviceimple.StudyBBSServiceImpl;
import javacafe.serviceimple.StudyMemberServiceImpl;
import javacafe.serviceimple.StudyServiceImpl;

public class InsertReplyAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
		
		int bp_no = Integer.parseInt( request.getParameter("bp_no") );
		int bbs_no = Integer.parseInt(request.getParameter("bbs_no"));
		int m_no = ((LoginInfoDTO)request.getSession().getAttribute("loginInfo")).getM_no();
		String br_writer = request.getParameter("br_writer");
		
		String br_content = request.getParameter("br_content");
		
		BbsPostService service = BbsPostServiceImple.getInstance();
		BbsPostReplyDTO replyDTO = new BbsPostReplyDTO();
		replyDTO.setBp_no(bp_no);
		replyDTO.setM_no(m_no);
		replyDTO.setBr_content(br_content);		
		replyDTO.setBbs_no(bbs_no);
		replyDTO.setBr_writer(br_writer);
		replyDTO.setBr_delflag(0);
		
		System.out.println("111"+bp_no);
		System.out.println(bbs_no);
		System.out.println(m_no);
		System.out.println(br_content);
		System.out.println(br_writer);
		
		service.insertReply(replyDTO);
		
				
		ActionForward forward = new ActionForward();
		forward.setUrl("freebbsboard");
				
		return forward;
	}

}
